function IcePart() {

	var iceFault = [];// [[时间，原因]]
	var iceRecord = [];// [[时间，厚度]]
	var iceSum = 0;
	
	var iceTable;

	this.load = function() {
		initIceDatas();
	};
	function initIceDatas() {
		initIceFault();
		initIceRecord();
	}
	function initIceFault() {
		$.getJSON('/rest/ice/getIceFaultByLineId/' + lineId, function(result) {
			iceFault = result;
			initIceFaultTable();
		});
	}
	function initIceRecord() {
		$.getJSON('/rest/ice/getIceByLineId/' + lineId, function(result) {
			iceRecord = result;
			initIceRecordChart();
		});
	}
	function getChartData() {
		var chartData = [];
		iceRecord = getSort(iceRecord, 0);
		if (iceRecord.length > 0) {
			for (var i = 0; i < iceRecord.length; i++) {
				chartData.push([ new Date(iceRecord[i][0]), iceRecord[i][1] ]);
				if (iceRecord[i][1] > 0) {
					iceSum++;
				}
			}
		}
		return chartData;
	}
	function initIceRecordChart() {
		var chartData = getChartData();
		$('#iceSum').html("共计" + iceSum + "天");
		$('#iceNum').html(iceSum);
		if (iceSum == 0) {
			$('#iceChart').html('无数据');
			$('#iceChart').addClass('no-data');
		} else {
			iceChart = new CategoryLine('iceChart');
			iceChart.setxAxisTitle("时间").setyAxis(chartData).setyAxisName(
					"覆冰厚度").setyAxisTitle("毫米");
			iceChart.addColor([ "#FFA07A" ]).setDataZoom(true).setDataView(
					false).setMagicType(false);

			var option = iceChart.getOption();
			option.color = [ 'blue' ];
			option.xAxis.type = 'time';
			option.dataZoom = [ {
				type : 'inside'
			}, {
				type : 'slider',
				dataBackground : {
					lineStyle : {
						color : 'blue',
						opacity : 1
					}
				}
			} ];

			var series = option.series[0];
			series.label.normal.show = iceSum == 1?true:false;
			series.label.emphasis.show = true;
			series.label.emphasis.position = 'top';
			series.showSymbol = iceSum == 1?true:false;
			series.areaStyle = {
				'normal' : {
					'color' : 'rgba(188,247,241,1)'
				}
			};
			iceChart.show();
		}
	}
	function initIceFaultTable() {
		$('#iceFaultSum').html("共计" + iceFault.length + "次");
		$('#iceFaultNum').html(iceFault.length);
		
		var columns = ['序号','故障时间', '故障类型','故障过程','备注' ];
		var opt = MyTable.getDefaultOptions();
		opt.paging = true;
		opt.pageLength = 5;
		iceTable = new MyTable("iceTable", columns, opt);
		var dataset = [];
		for ( var i in iceFault) {
			var f = iceFault[i];
			var dt = [Number(i)+1,DateUtil.dateTime(f.faultTime),str(f.faultType),str(f.description),str(f.remark)];
			dataset.push(dt);
		}
		iceTable.setDataSet(dataset);
		iceTable.show();
		
		function str(s){
			return s?s:"";
		}
	}
	// 将[[],[],]按照index的顺序从小到大排序
	function getSort(array, index) {
		array.sort(compare);
		function compare(obj1, obj2) {
			if (obj1 == undefined || obj1[index] == undefined
					|| obj1[index] == null) {
				return -1;
			}
			if (obj2 == undefined || obj1[index] == undefined
					|| obj1[index] == null) {
				return 1;
			}
			if (obj1[index] < obj2[index]) {
				return -1;
			} else {
				return 1;
			}
		}
		return array;
	}
	function initDisc() {
		var iceNum = document.getElementById('iceNum');
		var iceFaultNum = document.getElementById('iceFaultNum');
		iceNum.innerHTML = "覆冰    " + (ice.length - fault.length) + "次";
		iceFaultNum.innerHTML = "覆冰故障    " + fault.length + "次";
	}
	this.resizeHtml = function() {
		if (iceChart) {
			iceChart.getChart().resize();
		}
		if (iceTable) {
			iceTable.getTable().draw();
		}
	}
}
